package com.yy.permissions_general.utils.eleTree;

import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName EleTreeVo
 * @Description: TODO eleTree 封装
 * @Author YangYI
 * @Date 2022/1/13
 * @Version V1.0
 **/
@Data
public class EleTreeVo  implements Serializable {
    private static final long serialVersionUID = 1L;
    private Integer id;
    private Integer pId;
    private String label;
    private Boolean disabled;
    private Boolean checked;
    private Boolean radioDisabled;
    private Boolean isOpen;
    private Boolean isLeaf;
    /*临时字段 带参*/
    private String filedName1;
    private String filedName2;
    private String filedName3;
    private String filedName4;
    private List<EleTreeVo> children;

    /**
     * 递归
     * @param id 当前ID
     * @param list 集合
     * @return
     */
    public static List<EleTreeVo> eleTreeVoUtil(Integer id, List<EleTreeVo> list){
        List<EleTreeVo> trees = new ArrayList();
        for (EleTreeVo eleTreeVo : list) {
            if (eleTreeVo.getPId()== id){
                eleTreeVo.setChildren(eleTreeVoUtil(eleTreeVo.getId(),list));
                trees.add(eleTreeVo);
            }
        }
        return trees;
    }
}
